package br.com.tamagotchi.controle;

import br.com.tamagotchi.modelo.Dormir;
import br.com.tamagotchi.modelo.Tamagotchi;

public class SonoThread implements Runnable {

	Tamagotchi tamagotchi;

	public SonoThread(Tamagotchi tamagotchi) {
		this.tamagotchi = tamagotchi;
	}

	@Override
	public void run() {
		while (true) {
			try {
				if (!(tamagotchi.getIatividade() instanceof Dormir)
						|| (tamagotchi.getIatividade() != null)) {
					Thread.sleep(tamagotchi.getTempoSleep() * 1000);
					if (tamagotchi.getSono() < tamagotchi.getStatusMAX())
						tamagotchi.countSono();
				}
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
